package com.dragon.repository.domain.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BillDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "客户id")
    private Integer customerId;

    @ApiModelProperty(value = "累计实收金额")
    private Double paymentMoney;

    @ApiModelProperty(value = "累计应收金额")
    private Double planMoney;

    @ApiModelProperty(value = "结余金额")
    private Double balanceMoney;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date startTime;

    @ApiModelProperty(value = "结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date endTime;

    @ApiModelProperty(value = "账单子表")
    private List<BillPlan> billPlans;

    @ApiModelProperty(value = "客户名称")
    private String customerName;

    @ApiModelProperty(value = "累计应收金额")
    private Double accruedPlanMoney;

    @ApiModelProperty(value = "累计实收金额")
    private Double accruedPaymentMoney;

    @ApiModelProperty(value = "完成状态 0未完成 1已完成")
    private Integer isFinish;

    @ApiModelProperty(value = "客户创建人id")
    private Integer customerAdminId;

    @ApiModelProperty(value = "应收列表")
    private List<PlanCollect> planCollects;

    @ApiModelProperty(value = "报价产品信息")
    private List<QuotesProducts> quotesProductsList;


    public BillDTO() {}

    public BillDTO(Bill entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static BillDTO convert(Bill entity) {
        return new BillDTO(entity);
    }

    public static List<BillDTO> convertList(List<Bill> list) {
        List<BillDTO> resultList = new ArrayList<>();
        for (Bill entity : list) {
            resultList.add(new BillDTO(entity));
        }
        return resultList;
    }}
